package com.ruoyi.system.domain.wrapper.view;

import cn.hutool.core.bean.BeanUtil;
import com.eic.framework.core.domain.BaseEntityWrapperV;
import com.ruoyi.system.domain.dao.SysMenu;
import com.ruoyi.system.domain.view.SysMenuVo;

/**
 * 菜单权限前端实体包装
 *
 * @author 尹国春
 * @date 2022-07-25
 */
public class SysMenuWrapperV extends BaseEntityWrapperV<SysMenu, SysMenuVo> {

    private static SysMenuWrapperV wrapperV=null;
    //示例代码
    //private static IDemoDeptService demoDeptService;
    private SysMenuWrapperV(){
    }

    public static SysMenuWrapperV build(){
        if(wrapperV==null){
            //示例代码
            //demoDeptService= SpringUtils.getBean(IDemoDeptService.class);
            //Assert.notNull(demoDeptService);
            wrapperV=new SysMenuWrapperV();
        }
        return wrapperV;
    }

    @Override
    public SysMenuVo entityVO(SysMenu entity) {
        if(entity==null){
            return new SysMenuVo();
        }
        SysMenuVo vo = BeanUtil.copyProperties(entity,SysMenuVo.class);
        //示例代码
        //vo.setDeptName(getFieldValue(demoDeptService,entity.getDeptId(),DemoDept::getDepartName));
        return vo;
    }

    /*示例代码
    @Override
    public List<SysMenuVo> listVO(List<SysMenu> list) {
        List<SysMenuVo> voList=list.stream().map(user -> BeanUtil.copyProperties(user,SysMenuVo.class)).collect(Collectors.toList());
        copyForeignKeyData(voList,SysMenuVo::getDeptId,SysMenuVo::setDeptName,demoDeptService,DemoDept::getDepartName);
        return voList;
    }
    */
}